#!/usr/bin/env python

import sys

counter = {}

def reducer():
    for line in sys.stdin:
        if line[0]=='#':
            continue
        seg = line.strip().split('\t')
        key = seg[0]
        value = int(seg[1])
        c = int(counter.get(key,0))
        c+=value
        counter[key]=c

    for k,v in counter.iteritems():
        print "%s\t%s" %(k,v)

if __name__ == '__main__':
    reducer()
